<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/7
 * Time: 15:43
 */

namespace app\mobile\controller;


use app\common\controller\HomeBase;
use think\Db;
use think\Request;

class News extends HomeBase
{
    public function index()
    {
        $id                = Request::instance()->param('id');
        //栏目信息
        $category          = Db::name('category')
            ->field('id, title, thumb, seo_title, seo_keywords, seo_desc, list_tpl, article_tpl, attr')
            ->where('id', $id)
            ->find();
        if (empty($category))
        {
            return $this->fetch('/public/404');
        }
        $title             = $this->title;
        $description       = $this->description;
        $keywords          = $this->keywords;
        //标题
        if (!empty($category['seo_title']))
        {
            $title = $category['seo_title'];
        }
        //关键字
        if (!empty($category['seo_keywords']))
        {
            $keywords = $category['seo_keywords'];
        }
        //描述
        if (!empty($category['seo_desc']))
        {
            $description = $category['seo_desc'];
        }
        //模版文件
        $tpl = $category['list_tpl'];
        return view("/$tpl", [
            'category'    => $category,
            'title'       => $title,
            'keywords'    => $keywords,
            'description' => $description,
        ]);
    }

    //空操作
    public function _empty($name)
    {
        return view('/public/404');
    }
}